From dedb00f212bbfbe4336f021844afd7c950455b26 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 8 Aug 2006 11:45:37 +0100 Subject: [PATCH] [XEN] Make tlbflush_time a PER_CPU variable. Signed-off-by: Keir Fraser --- xen/arch/powerpc/setup.c | 2 +- xen/arch/x86/flushtlb.c | 4 ++-- xen/arch/x86/x86_32/domain_page.c | 3 +-- xen/include/asm-powerpc/flushtlb.h | 15 ++++++++------- xen/include/asm-x86/current.h | 2 +- xen/include/asm-x86/flushtlb.h | 16 +++++++++------- xen/include/xen/percpu.h | 1 - 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/xen/arch/powerpc/setup.c b/xen/arch/powerpc/setup.c index dbb4dfe0b8..8c064d6cb0 100644 --- a/xen/arch/powerpc/setup.c +++ b/xen/arch/powerpc/setup.c @@ -55,7 +55,7 @@ int opt_earlygdb = 0; boolean_param("earlygdb", opt_earlygdb); u32 tlbflush_clock = 1U; -u32 tlbflush_time[NR_CPUS]; +DEFINE_PER_CPU(u32, tlbflush_time); unsigned int watchdog_on; unsigned long wait_init_idle; diff --git a/xen/arch/x86/flushtlb.c b/xen/arch/x86/flushtlb.c index 5e132a7a14..e3415dd3dd 100644 --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -20,7 +20,7 @@ #endif u32 tlbflush_clock = 1U; -u32 tlbflush_time[NR_CPUS]; +DEFINE_PER_CPU(u32, tlbflush_time); void write_cr3(unsigned long cr3) { @@ -71,7 +71,7 @@ void write_cr3(unsigned long cr3) * case, so really we are being ultra paranoid. */ - tlbflush_time[smp_processor_id()] = t2; + this_cpu(tlbflush_time) = t2; local_irq_restore(flags); } diff --git a/xen/arch/x86/x86_32/domain_page.c b/xen/arch/x86/x86_32/domain_page.c index 4a7362d7e2..db3237242c 100644 --- a/xen/arch/x86/x86_32/domain_page.c +++ b/xen/arch/x86/x86_32/domain_page.c @@ -73,8 +73,7 @@ void *map_domain_page(unsigned long pfn) if ( unlikely(cache->epoch != cache->shadow_epoch[vcpu]) ) { cache->shadow_epoch[vcpu] = cache->epoch; - if ( NEED_FLUSH(tlbflush_time[smp_processor_id()], - cache->tlbflush_timestamp) ) + if ( NEED_FLUSH(this_cpu(tlbflush_time), cache->tlbflush_timestamp) ) { perfc_incrc(domain_page_tlb_flush); local_flush_tlb(); diff --git a/xen/include/asm-powerpc/flushtlb.h b/xen/include/asm-powerpc/flushtlb.h index 67e454a0fd..9b77c46f1f 100644 --- a/xen/include/asm-powerpc/flushtlb.h +++ b/xen/include/asm-powerpc/flushtlb.h @@ -22,6 +22,7 @@ #define _ASM_FLUSHTLB_H_ #include +#include #include #include @@ -30,7 +31,7 @@ extern u32 tlbflush_clock; #define tlbflush_current_time() tlbflush_clock /* Time at which each CPU's TLB was last flushed. */ -extern u32 tlbflush_time[NR_CPUS]; +DECLARE_PER_CPU(u32, tlbflush_time); static inline int NEED_FLUSH(u32 cpu_stamp, u32 lastuse_stamp) { @@ -44,12 +45,12 @@ static inline int NEED_FLUSH(u32 cpu_stamp, u32 lastuse_stamp) * Filter the given set of CPUs, removing those that definitely flushed their * TLB since @page_timestamp. */ -#define tlbflush_filter(mask, page_timestamp) \ -do { \ - unsigned int cpu; \ - for_each_cpu_mask ( cpu, mask ) \ - if ( !NEED_FLUSH(tlbflush_time[cpu], page_timestamp) ) \ - cpu_clear(cpu, mask); \ +#define tlbflush_filter(mask, page_timestamp) \ +do { \ + unsigned int cpu; \ + for_each_cpu_mask ( cpu, mask ) \ + if ( !NEED_FLUSH(per_cpu(tlbflush_time, cpu), page_timestamp) ) \ + cpu_clear(cpu, mask); \ } while ( 0 ) diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index 9b0b6e5245..0a423fba67 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -8,6 +8,7 @@ #define __X86_CURRENT_H__ #include +#include #include #include @@ -53,7 +54,6 @@ static inline struct cpu_info *get_cpu_info(void) #define schedule_tail(vcpu) (((vcpu)->arch.schedule_tail)(vcpu)) -#include /* * Which VCPU's state is currently running on each CPU? * This is not necesasrily the same as 'current' as a CPU may be diff --git a/xen/include/asm-x86/flushtlb.h b/xen/include/asm-x86/flushtlb.h index 4cc3a41c67..82cb7a7cfe 100644 --- a/xen/include/asm-x86/flushtlb.h +++ b/xen/include/asm-x86/flushtlb.h @@ -11,13 +11,15 @@ #define __FLUSHTLB_H__ #include +#include #include +#include /* The current time as shown by the virtual TLB clock. */ extern u32 tlbflush_clock; /* Time at which each CPU's TLB was last flushed. */ -extern u32 tlbflush_time[NR_CPUS]; +DECLARE_PER_CPU(u32, tlbflush_time); #define tlbflush_current_time() tlbflush_clock @@ -47,12 +49,12 @@ static inline int NEED_FLUSH(u32 cpu_stamp, u32 lastuse_stamp) * Filter the given set of CPUs, removing those that definitely flushed their * TLB since @page_timestamp. */ -#define tlbflush_filter(mask, page_timestamp) \ -do { \ - unsigned int cpu; \ - for_each_cpu_mask ( cpu, mask ) \ - if ( !NEED_FLUSH(tlbflush_time[cpu], page_timestamp) ) \ - cpu_clear(cpu, mask); \ +#define tlbflush_filter(mask, page_timestamp) \ +do { \ + unsigned int cpu; \ + for_each_cpu_mask ( cpu, mask ) \ + if ( !NEED_FLUSH(per_cpu(tlbflush_time, cpu), page_timestamp) ) \ + cpu_clear(cpu, mask); \ } while ( 0 ) extern void new_tlbflush_clock_period(void); diff --git a/xen/include/xen/percpu.h b/xen/include/xen/percpu.h index 88fba30e8a..34635892a5 100644 --- a/xen/include/xen/percpu.h +++ b/xen/include/xen/percpu.h @@ -2,7 +2,6 @@ #define __XEN_PERCPU_H__ #include -#include #include /* Preferred on Xen. Also see arch-defined per_cpu(). */ -- 2.30.2